//
//  CounterAboutViewController.m
//  GoodsCountingCounter
//
//  Created by iOSdev on 2024/7/23.
//

#import "CounterAboutViewController.h"
#import "Colours/Colours.h"
#import "SJAttributesFactory.h"

#define MAS_SHORTHAND
#define MAS_SHORTHAND_GLOBALS
#import "Masonry.h"

@interface CounterAboutViewController ()<UITextViewDelegate>

@property (nonatomic, strong)UILabel *version;

@property (nonatomic, strong) UITextView *textView;


@end

@implementation CounterAboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.backgroundColor = [UIColor snowColor];
    self.navigationItem.title = @"About";
    
    [self showBGVersion];

    // 初始化textView
    self.textView = [[UITextView alloc] init];
    self.textView.layer.cornerRadius = 5.0;
    self.textView.layer.masksToBounds = YES;
    self.textView.delegate = self; // 设置代理为当前控制器
    
//    self.textView.font = [UIFont systemFontOfSize:16]; // 设置字体
//    self.textView.textColor = [UIColor blackColor]; // 设置文本颜色
    self.textView.editable = NO; // 设置可编辑
    self.textView.scrollEnabled = YES; // 设置可滚动
    

    NSAttributedString *attributedString = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol>  _Nonnull make) {
        make.font([UIFont systemFontOfSize:18]).textColor(UIColor.blackColor).lineSpacing(8);
        make.append(@"   The counting counter is used for counting items, and can be used for counting goods in terminals, warehouses, libraries and other scenes.").textColor(UIColor.grapefruitColor).font([UIFont boldSystemFontOfSize:20]);
        make.append(@"\n");
        
        make.append(@"\n");
        make.append(@"There are three ways to count: one by one, two at a time, and dozens by dozens. \nAppk can also keep a log of the count for later statistics");

    }];
    // 添加textView到视图中
    [self.view addSubview:self.textView];
    [self.textView makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(self.view).with.insets(UIEdgeInsetsMake(10, 10, 10, 10));
        make.left.equalTo(self.view.left).offset(10);
        make.top.equalTo(self.version.bottom);
        make.right.equalTo(self.view.right).offset(-10);
        make.bottom.equalTo(self.view.bottom).offset(-10);
    }];
    
    self.textView.attributedText = attributedString;
}

- (void)showBGVersion {
    //图片
    UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"atad"]];
    [self.view addSubview:image];
    [image makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.top);
        make.left.right.equalTo(self.view);
        make.height.equalTo(self.view.width).multipliedBy(210.0/389.0);
    }];
    
    //Version
    self.version = [[UILabel alloc] init];
    self.version.textAlignment = NSTextAlignmentCenter;
    self.version.font = [UIFont systemFontOfSize:13];
    self.version.textColor = UIColor.blackColor;
    self.version.text = @"Version:1.0";
    [self.view addSubview:self.version];
    [self.version makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.left);
        make.bottom.equalTo(image.bottom).offset(0);
        make.right.equalTo(self.view.right);
        make.height.equalTo(30);
    }];
}

/*
 The counting counter is used for counting items, and can be used for counting goods in terminals, warehouses, libraries and other scenes.
 There are three ways to count: one by one, two at a time, and dozens by dozens
 Appk can also keep a log of the count for later statistics
*/

@end
